package net.tngou.crawler.util;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;

import org.apache.commons.configuration2.FileBasedConfiguration;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Parameters;
import org.apache.commons.io.FileUtils;

/**
 * 文档模板
 * @author tngou@tngou.net
 *
 */
public class DocTemp {

	//空文档
	public static String T_NULL="doc/null.html";
	//接口文档
	public static String T_API="doc/api.html";
	//数据字典
	public static String T_DATA="doc/data.html";
	//更新日志
	public static String T_LOG="doc/log.html";
	//错误码
	public static String T_ERROR="doc/error.html";
	
	
	
	public static  String GetTemp(String filename) {
		Parameters params = new Parameters();
		@SuppressWarnings({ "rawtypes", "unchecked" })
		FileBasedConfigurationBuilder<?> builder =
			    new FileBasedConfigurationBuilder(FileBasedConfiguration.class)
			    .configure(params.properties()
			        .setFileName(filename));
		URL url = builder.getFileHandler().getURL();
		try {
			File file = new File(url.toURI());
			String s = FileUtils.readFileToString(file, "UTF-8");
			return s;
		} catch (URISyntaxException | IOException e) {
		
			e.printStackTrace();
		}
		return "";
	}
}
